<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/11/30
 * Time: 18:21
 */
require_once(dirname(__FILE__) . '/../../inc/config.inc.php');
IsModelPriv('member');

$page = isset($_GET['page']) ? intval($_GET['page']) : 0;
$size = isset($_GET['limit']) ? intval($_GET['limit']) : 0;
$username = isset($_GET['username']) ? htmlspecialchars($_GET['username']) : "";
$username=trim($username);
$nickname = isset($_GET['nickname']) ? htmlspecialchars($_GET['nickname']) : "";
$nickname=trim($nickname);
//$id= isset($_GET['id']) ? intval($_GET['id']) : "";
$mobile = isset($_GET['mobile']) ? htmlspecialchars($_GET['mobile']) : "";
$mobile=trim($mobile);
$dtime = isset($_GET['dtime']) ? htmlspecialchars($_GET['dtime']) : "";   //用车人
$dtime=trim($dtime);
$level = isset($_GET['level']) ? intval($_GET['level']) : 0;   //用户的身份
$start_num = ($page - 1) * $size;



$sql="SELECT *  FROM `#@__user` where 1   ";

if ($level>0) {
    $sql .= "  and level='$level' ";
}

if (!empty($truename)) {
    $sql .= "  and truename like '%$truename%'  ";
}
if (!empty($nickname)) {
    $sql .= "  and nickname like '%$nickname%'  ";
}
if (!empty($mobile)) {
    $sql .= "  and mobile like '%$mobile%'  ";
}
if ($dtime != "") {
    $time_arr = explode("~", $dtime);
    if (is_array($time_arr) && count($time_arr) == 2) {
        $start_time = strtotime(trim($time_arr[0]));
        $end_time = strtotime(trim($time_arr[1]))+ 3600 * 24 - 1;
        $sql .= " AND regtime>'$start_time' AND regtime<'$end_time' ";

    }

}



$dosql->Execute($sql,8);
$count=$dosql->GetTotalRow(8);
$sql.=" order by id desc  LIMIT $start_num, $size ";
$dosql->Execute($sql);
while ($row = $dosql->GetArray()) {
//    $row['picurl_url'] = "/".$row['picurl'];
    $row['addtime'] = GetDateTime($row['regtime']);
    $row_arr['data'][] = $row;
}
if (empty($row_arr['data'])) {
    $row_arr['data'][] = [];
}
$row_arr['code'] = 0;
$row_arr['msg'] = "success";
$row_arr['count'] = $count;
echo json_encode($row_arr);